// 控制动画效果
function CacheaniScroll(idname, type) {
  if (($("#" + idname).offset().top - $(window).scrollTop()) < $(window).height()) {
    $("#" + idname).children(".items").find(".item").addClass("animate__animated");
    $("#" + idname).children(".items").find(".item").addClass(type);
  };
  $(window).scroll(function () {
    if (($("#" + idname).offset().top - $(window).scrollTop()) < $(window).height()) {
      $("#" + idname).children(".items").find(".item").addClass("animate__animated");
      $("#" + idname).children(".items").find(".item").addClass(type);
    };
  });

  // setTimeout(function(){
  //     $("#"+idname).children(".items").find(".item").removeClass("animate__animated");
  //     $("#"+idname).children(".items").find(".item").removeClass(type);
  // }, 1000);
};

function Classani(classname, type) {
  $("." + classname).addClass("animate__animated");
  $("." + classname).addClass(type);
  setTimeout(function () {
    $("." + classname).removeClass("animate__animated");
    $("." + classname).removeClass(type);
  }, 1000);
}

function Idani(idname, type) {
  $("#" + idname).addClass("animate__animated");
  $("#" + idname).addClass(type);
  setTimeout(function () {
    $("#" + idname).removeClass("animate__animated");
    $("#" + idname).removeClass(type);
  }, 1000);
}


function IdaniScroll(idname, type) {
  if (($("#" + idname).offset().top - $(window).scrollTop()) < $(window).height()) {
    $("#" + idname).addClass("animate__animated");
    $("#" + idname).addClass(type);
  };
  $(window).scroll(function () {
    if (($("#" + idname).offset().top - $(window).scrollTop()) < $(window).height()) {
      $("#" + idname).addClass("animate__animated");
      $("#" + idname).addClass(type);
    };
  });

  //移除
  setTimeout(function () {
    $("#" + idname).removeClass("animate__animated");
    $("#" + idname).removeClass(type);
  }, 1000);
}

window.onload = function () {
  //效果调整
  CacheaniScroll("cate2", "animate__bounceInDown");
  CacheaniScroll("cate3", "animate__fadeInDownBig");
  CacheaniScroll("cate4", "animate__fadeInDownBig");
  CacheaniScroll("cate5", "animate__fadeInDownBig");
  CacheaniScroll("cate9", "animate__fadeInDownBig");

  //左侧侧边栏动画 --加了如果不设置移除会使停靠失效
  Classani("quick-nav", "animate__rollIn");
  //右侧条框
  Idani("cate2", "animate__lightSpeedInRight");

  IdaniScroll("cate3", "animate__rotateInDownRight");
  IdaniScroll("cate4", "animate__rotateInDownRight")
  IdaniScroll("cate5", "animate__rotateInDownRight")
  IdaniScroll("cate9", "animate__rotateInDownRight")

}
